package com.api.shopapi.service.impl;


import com.api.shopapi.entity.OrderGoods;
import com.api.shopapi.entity.dto.OrderGoodsDTO;
import com.api.shopapi.entity.dto.OrderGoodsDTO1;
import com.api.shopapi.mapper.OrderGoodsMapper;
import com.api.shopapi.service.OrderGoodsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("OrderGoodsServiceImplOne")
public class OrderGoodsServiceImpl implements OrderGoodsService {

    @Autowired
    private OrderGoodsMapper orderGoodsMapper;

    @Override
    public int insert(OrderGoods orderGoods) {
        return orderGoodsMapper.insert(orderGoods);
    }

    @Override
    public int delete(String orderGoodsCode) {
        return orderGoodsMapper.delete(orderGoodsCode);
    }

    @Override
    public int update(OrderGoods orderGoods) {
        return orderGoodsMapper.update(orderGoods);
    }

    @Override
    public List<OrderGoods> getList() {
        return orderGoodsMapper.getList();
    }

    @Override
    public OrderGoods getByOrderGoodsCode(String orderGoodsCode) {
        return orderGoodsMapper.getByOrderGoodsCode(orderGoodsCode);
    }

    @Override
    public List<OrderGoodsDTO> getListByOrderBusinessCode(String orderBusinessCode){
        return orderGoodsMapper.getListByOrderBusinessCode(orderBusinessCode);
    }

    @Override
    public OrderGoods getByOrderBusinessCode(String orderBusinessCode) {
        return orderGoodsMapper.getByOrderBusinessCode(orderBusinessCode);
    }

    @Override
    public List<OrderGoods> getByOrderBusinessCodeForPage(String orderBusinessCode,String businessCode) {
        return orderGoodsMapper.getByOrderBusinessCodeForPage(orderBusinessCode,businessCode);
    }

    @Override
    public PageInfo<OrderGoodsDTO1> businessConsumerOrderInfo(int pageIndex, int pageSize, String startTime, String endTime, int orderType, String businessCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderGoodsDTO1> orderGoodsDTO1List = orderGoodsMapper.businessConsumerOrderInfo(startTime, endTime, orderType, businessCode);
        return new PageInfo<>(orderGoodsDTO1List);
    }

    @Override
    public PageInfo<OrderGoodsDTO1> userConsumerOrderInfo(int pageIndex, int pageSize, String userCode, String startTime, String endTime, int orderType, String businessCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderGoodsDTO1> orderGoodsDTO1List = orderGoodsMapper.userConsumerOrderInfo(userCode,startTime, endTime, orderType, businessCode);
        return new PageInfo<>(orderGoodsDTO1List);
    }

    @Override
    public List<OrderGoodsDTO1> exportBusinessConsumerOrderInfo(String startTime, String endTime, int orderType, String businessCode) {
        return orderGoodsMapper.businessConsumerOrderInfo(startTime, endTime, orderType, businessCode);
    }

}